package com.nit.tools.document;

import cn.hutool.core.io.FileUtil;
import com.nit.tools.FileReadUtil;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.data.MutableDataSet;

import java.io.File;

public class MkTools {

    public static void main(String[] args) throws Exception {
        MutableDataSet options = new MutableDataSet();

        // uncomment to set optional extensions
        //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()));

        // uncomment to convert soft-breaks to hard breaks
        //options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");


        // You can re-use parser and renderer instances
//        Node document = parser.parse("This is *Sparta*");
//        String html = renderer.render(document);  // "<p>This is <em>Sparta</em></p>\n"
//        System.out.println(html);

        String md = FileReadUtil.readAll("F:\\仓库\\gitee\\nit-doc\\java\\springboot笔记.md");
        Parser parser = Parser.builder(options).build();
        HtmlRenderer renderer = HtmlRenderer.builder(options).build();
        Node document2 = parser.parse(md);
        String html2 = renderer.render(document2);  // "<p>This is <em>Sparta</em></p>\n"
        System.out.println(html2);

        FileUtil.writeString(html2, new File("D://doc//doc_test/test.html"), "utf-8");
    }
}
